<?php
namespace Home\Model;
use Think\Model;
class TribeModel extends Model{ 
	public function getTribeInfoById($tr_id,$userId){
		$tribeInfo = M("Tribe")->find($tr_id);
		$userInfo = M("User")->find($userId);

		$sysconfig = C('sysconfig');
		$condition['sc_id'] = $sysconfig['tribe'];
		$tribeConfig = M("SystemConfig")->where($condition)->find();
        $tribeInfo['tr_member_num_max'] = $tribeConfig['sc_value'];
		$condition = array(
			'us_tribe_id'=>$tr_id,
			'us_tribe_status'=>array('not in',array(1,3)),
		);
		$tribeInfo['members'] = M("User")->where($condition)->order("us_tribe_level desc")->select();
		$tribeInfo['can_get_reward_status'] = 0;//不能领取
		$tribeInfo['can_get_cloud_money'] = 0;
		if($userInfo['us_tribe_id']==$tr_id&&$tribeInfo['tr_level']>0){
			if(time()>$userInfo['us_tribe_next_time']){
				$tribe_level = M("TribeLevel")->where(array('tl_level'=>$tribeInfo['tr_level']))->find();
				if(!empty($tribe_level)){
					$tribeInfo['can_get_reward_status'] = 1;//可以领取
					$can_get_cloud_money = $tribe_level['tl_get_cloude_'.$userInfo['us_tribe_level']];
					$tribeInfo['can_get_cloud_money'] = $can_get_cloud_money?$can_get_cloud_money:0;
				}
			}
		}
		return $tribeInfo;
	}
}
?>